﻿/*************************************************************************************
 * 文 件 名:   HKDebug
 
 * 功能描述：   1.对Unity原生的Debug进行封装，外界可通过HKDebug.Log等方法进行调用
 *             2.Log时，可通过设置LogColor、LogStyle参数，快捷设置Log的字体颜色及样式
                   
 * 版    本：   V1.0
 * 创 建 者：   谭潇杰、京产肠饭
 * 创建时间：   2024/1/28
 * 链    接：   https://gitee.com/JingChanChangFan/hk_-unity-tools
*************************************************************************************/

using UnityEngine;

namespace HKTools
{
    public enum LogColor
    {
        White,
        Red,
        Yellow,
        Green,
        Blue,
        Cyan
    }

    public enum LogStyle
    {
        Normal,
        Bold,
        Italic,
        BoldAndItalic
    }

    public class HKDebug : Debug
    {
        public static void Log(string message, LogColor color = LogColor.White, LogStyle style = LogStyle.Normal)
        {
            string prefix = string.Empty;
            string suffix = string.Empty;

            switch (style)
            {
                case LogStyle.Bold:
                    prefix += "<b>";
                    break;
                case LogStyle.Italic:
                    prefix += "<i>";
                    break;
                case LogStyle.BoldAndItalic:
                    prefix += "<b><i>";
                    break;
            }

            switch (color)
            {
                case LogColor.Red:
                    prefix += "<color=red>";
                    suffix += "</color>";
                    break;
                case LogColor.Yellow:
                    prefix += "<color=#FFD400>";
                    suffix += "</color>";
                    break;
                case LogColor.Green:
                    prefix += "<color=green>";
                    suffix += "</color>";
                    break;
                case LogColor.Blue:
                    prefix += "<color=#0089FF>";
                    suffix += "</color>";
                    break;
                case LogColor.Cyan:
                    prefix += "<color=#00FFFF>";
                    suffix += "</color>";
                    break;
            }

            switch (style)
            {
                case LogStyle.Normal:
                    break;
                case LogStyle.Bold:
                    suffix += "</b>";
                    break;
                case LogStyle.Italic:
                    suffix += "</i>";
                    break;
                case LogStyle.BoldAndItalic:
                    suffix += "</i></b>";
                    break;
            }

            unityLogger.Log(LogType.Log, prefix + message + suffix);
        }
    }
}